package com.ruoyi.training.service.impl;

import java.util.List;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.training.util.xuehua.SnowflakeIdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.training.mapper.RemarksMapper;
import com.ruoyi.training.domain.Remarks;
import com.ruoyi.training.service.IRemarksService;

/**
 * 备注Service业务层处理
 *
 * @author hcc
 * @date 2025-09-24
 */
@Service
public class RemarksServiceImpl implements IRemarksService {
    @Autowired
    private RemarksMapper remarksMapper;

    /**
     * 查询备注
     *
     * @param remarkId 备注主键
     * @return 备注
     */
    @Override
    public Remarks selectRemarksByRemarkId(String remarkId) {
        return remarksMapper.selectRemarksByRemarkId(remarkId);
    }

    /**
     * 查询备注列表
     *
     * @param remarks 备注
     * @return 备注
     */
    @Override
    public List<Remarks> selectRemarksList(Remarks remarks) {
        return remarksMapper.selectRemarksList(remarks);
    }

    /**
     * 新增备注
     *
     * @param remarks 备注
     * @return 结果
     */
    @Override
    public int insertRemarks(Remarks remarks) {
        remarks.setRemarkId(String.valueOf(new SnowflakeIdUtils(5,8).nextId()));
        remarks.setCreateTime(DateUtils.getNowDate());
        remarks.setCreateBy(SecurityUtils.getUsername());
        return remarksMapper.insertRemarks(remarks);
    }

    /**
     * 修改备注
     *
     * @param remarks 备注
     * @return 结果
     */
    @Override
    public int updateRemarks(Remarks remarks) {
        remarks.setUpdateTime(DateUtils.getNowDate());
        return remarksMapper.updateRemarks(remarks);
    }

    /**
     * 批量删除备注
     *
     * @param remarkIds 需要删除的备注主键
     * @return 结果
     */
    @Override
    public int deleteRemarksByRemarkIds(String[] remarkIds) {
        return remarksMapper.deleteRemarksByRemarkIds(remarkIds);
    }

    /**
     * 删除备注信息
     *
     * @param remarkId 备注主键
     * @return 结果
     */
    @Override
    public int deleteRemarksByRemarkId(String remarkId) {
        return remarksMapper.deleteRemarksByRemarkId(remarkId);
    }

    /**
     * 查询备注历史列表
     */
    @Override
    public List<Remarks> selectRemarksHistoryList(Remarks remarks) {
        return remarksMapper.selectRemarksHistoryList(remarks);
    }

    /**
     * 查询备注通过外键id
     */
    @Override
    public Remarks selectRemarksByForeignId(String foreignId, String remarkType) {
        return remarksMapper.selectRemarksByForeignId(foreignId, remarkType);
    }
}
